//
//  ddqueue.h
//  kasama1
//
//  Created by 丁逸鹏 on 15/3/3.
//
//

#ifndef __kasama1__ddqueue__
#define __kasama1__ddqueue__

#include <iostream>
using namespace std;
template <class T>
class DDqueue
{
public:
    void push(T element);
    DDqueue(int size=2);
    void clear();
    T *element;
    int maxSize;
    int length;
};
template<class T>
DDqueue<T>::DDqueue(int size)
{
    element=new T[size];
    this->maxSize=size;
    length=0;
}
template<class T>
void DDqueue<T>::push(T x)
{
    for(int i=0;i<length;i++)
    {
        if(x==element[i])
        {
            return;//≤ªƒ‹≤Â»Î÷ÿ∏¥µƒ
        }
    }
    if(length<maxSize)
    {
        element[length]=x;
        length++;
    }else
    {
        for(int i=0;i<maxSize-1;i++)
        {
            element[i]=element[i+1];
        }
        element[maxSize-1]=x;
    }
}
template<class T>
void DDqueue<T>::clear()
{
    length=0;
}


#endif /* defined(__kasama1__ddqueue__) */
